// 统一接口响应数据格式
const responseHandler = async(ctx, next) => {
    ctx.send = (data = null, msg = 'success', code = 200, error = null, serviceCode = 200) => {
        ctx.body = {
            msg, //提示
            error, //错误说明
            serviceCode, //业务错误码
            data //返给前端的数据
        } 
        ctx.status = code;
    }
    await next();
}

module.exports = responseHandler;